package main

import (
	"fmt"
	"reflect"
)

type user struct {
	Id   int
	Name string
	Age  int
}

func (u user) call() {
	fmt.Println("call")
	fmt.Printf("%v\n", u)
}

func doFiledAndMethod(input interface{}) {
	inputType := reflect.TypeOf(input)
	fmt.Println("inputType =", inputType)

	inputValue := reflect.ValueOf(input)
	fmt.Println("inputValue =", inputValue)

	for i := 0; i < inputType.NumField(); i++ {
		field := inputType.Field(i)
		value := inputValue.Field(i).Interface()
		fmt.Printf("%s : %v = %v\n", field.Name, field.Type, value)
	}

	for i := 0; i < inputType.NumMethod(); i++ {
		m := inputType.Method(i)
		fmt.Printf("%s: %v\n", m.Name, m.Type)
	}
}

func main() {
	u := user{1, "fb", 18}
	doFiledAndMethod(u)
}
